import request from "@/utils/request";
import { RoleForm } from "./types";
/**
 * 添加角色
 * @param data
 */
export function addRole(data: RoleForm) {
  return request({
    url: "/stasx/org/roles/add/v1",
    method: "post",
    data,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
  });
}

/**
 * 角色列表
 * @param data
 */
export function getRole(data: any) {
  return request({
    url: "/stasx/org/roles/list/v1",
    method: "get",
    params: data,
  });
}

/**
 * 更新角色
 * @param data
 */
export function updateRole(data: any) {
  return request({
    url: "/stasx/org/roles/update/v1",
    method: "post",
    data,
  });
}

/**
 * 删除角色
 * @param data
 */
export function deleteRoles(data: any) {
  return request({
    url: "/stasx/org/roles/delete/v1",
    method: "delete",
    data,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
  });
}

/**
 * 添加机构角色
 * @param data
 */
export function setAddRole(data: any) {
  return request({
    url: "/stasx/org/roles/setUserRole/v1",
    method: "post",
    data,
  });
}

/**
 * 机构角色下的用户列表
 * @param data
 */
export function getUsersRole(data: any) {
  return request({
    url: "/stasx/org/roles/users/v1",
    method: "get",
    params: data,
  });
}

/**
 * 列出用户，用于将用户加入角色
 * @param data
 */

export function getListUsers2chose(data: any) {
  return request({
    url: "/stasx/org/roles/listUsers2chose/v1",
    method: "get",
    params: data,
  });
}

/**
 * 将用户从角色中移除
 * @param data
 */
export function deleteFromOrg(queryParams: any) {
  return request({
    url: "/stasx/org/roles/removeRoleFromUser/v1",
    method: "delete",
    data: queryParams,
  });
}
